//
//  ViewController.swift
//  WaterAnimation
//
//  Created by Ming on 2018/12/5.
//  Copyright © 2018年 Insta360. All rights reserved.
//

import UIKit


class ViewController: UIViewController {

    @IBOutlet weak var waterView: HUMWaterView!
    
    var timer: Timer?
    
    override func viewDidLoad() {
        super.viewDidLoad()
    }
    
    @IBAction func handleBegin(_ sender: Any) {
        if timer == nil {
            timer = Timer(timeInterval: waterView.dropDuration, target: self, selector: #selector(handleTick), userInfo: nil, repeats: true)
            RunLoop.main.add(timer!, forMode: .common)
            handleTick()
        } else {
            timer?.invalidate()
            timer = nil
        }
    }
    
    @objc func handleTick() {
        waterView.addWaterDrop()
    }
    

}


